import * as echarts from 'echarts'

const colorList = [
  '#768BFF', '#66CCCC', '#CCFF99', '#F4CB29',
  '#C6E579', '#FD9E06', '#f3d999', '#FFFFCC',
  '#02CBF9', '#3cb371', '#CCFFFF', '#CCCCFF',
  '#FF9999', '#FFCC99', '#99CC99', '#99CCFF',
  '#99CCCC', '#99CCFF', '#29CCA0', '#2E8DE6',
];
//化石燃料燃烧碳排放
const gdztzb = {
    tooltip: {
      show: true,
      trigger: 'item',
      formatter: '{b}t'
    },
    legend: {
      bottom: "20",
      // right: "20px",
      // orient: "vertical", // 垂直显示图例
      icon: "roundRect",
      itemHeight: 12,
      itemWidth: 20,
      itemGap: 10,
      textStyle: {
        //图例文字的样式
        color: "#FFFFFF",
        fontSize: 12
      }
    },
    series: [
      {
        name: "",
        type: "pie",
        radius: ["40%", "65%"],
        center: ["50%", "40%"],
        avoidLabelOverlap: false,
        // 关键代码========================
        label: {
          normal: {
            show: false,
            position: "outer",
            formatter: (item) => {
              let { name, value } = item;
              return `{a|${name}} {b|${value}}`;
            },
            // padding: [0, -58],
            rich: {
              a: {
                fontSize: 12,
                color: "#FFFFFF",
                padding: [5, 0, 0, 0]
              },
              b: {
                fontSize: 12,
                color: "#FFFFFF",
                padding: [5, 0, 0, 0]
              },
              c: {
                fontSize: 16,
                color: "#FFFFFF",
                fontWeight: "bold",
                align: "left"
              },
              d: {
                fontSize: 16,
                color: "#FFFFFF",
                fontWeight: "bold",
                align: "right"
              }
            }
          }
        },
        // 关键代码========================
        labelLine: {
          normal: {
            show: false,
            length: 5,
            length2: 50,
            lineStyle: {
              color: "#47A0FF"
            }
          }
        },
        emphasis: {
          show: true,
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)"
          }
        },
        data: [
          {name: "固体燃料",
            value: 1,
            itemStyle: {
              color: {
                colorStops: [{offset: 0, color: "#008eec"},
                  {offset: 1, color: "#008EEC"}],
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false
              }
            }
          },
          {name: "液体燃料",
            value: 0,
            itemStyle: {
              color: {
                colorStops: [{offset: 0, color: "#5c63e3"},
                  {offset: 1, color: "#5c82e3"}],
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false
              }
            }
          },
          {name: "气体燃料",
            value: 0,
            itemStyle: {
              color: {
                colorStops: [{offset: 0, color: "rgba(162,227,92,0.85)"},
                  {offset: 1, color: "rgba(162,227,92,0.85)"}],
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false
              }
            }
          },
        ]
      }
    ]
};
//购入使用电力热力产生碳排放
const gdsbzb = {
  tooltip: {
    show: true,
    trigger: 'item',
    formatter: '{b}t'
  },
  legend: {
    bottom: "20",
    // right: "20px",
    // orient: "vertical", // 垂直显示图例
    icon: "roundRect",
    itemHeight: 12,
    itemWidth: 20,
    itemGap: 10,
    textStyle: {
      //图例文字的样式
      color: "#FFFFFF",
      fontSize: 12
    }
  },
  series: [
    {
      name: "",
      type: "pie",
      radius: ["40%", "65%"],
      center: ["50%", "40%"],
      avoidLabelOverlap: false,
      // 关键代码========================
      label: {
        normal: {
          show: false,
          position: "outer",
          formatter: (item) => {
            let { name, value } = item;
            return `{a|${name}} {b|${value}}`;
          },
          // padding: [0, -58],
          rich: {
            a: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            b: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            c: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "left"
            },
            d: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "right"
            }
          }
        }
      },
      // 关键代码========================
      labelLine: {
        normal: {
          show: false,
          length: 5,
          length2: 50,
          lineStyle: {
            color: "#47A0FF"
          }
        }
      },
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: "rgba(0, 0, 0, 0.5)"
        }
      },
      data: [
        {name: "购入电力",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#008eec"},
                {offset: 1, color: "#008EEC"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "购入热力",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "rgba(162,227,92,0.85)"},
                {offset: 1, color: "rgba(162,227,92,0.85)"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
      ]
    }
  ]
};

//过程碳排放
const gdslqs = {
  tooltip: {
    show: true,
    trigger: 'item',
    formatter: '{b}t'
  },
  legend: {
    bottom: "20",
    // right: "20px",
    // orient: "vertical", // 垂直显示图例
    icon: "roundRect",
    itemHeight: 12,
    itemWidth: 20,
    itemGap: 10,
    textStyle: {
      //图例文字的样式
      color: "#FFFFFF",
      fontSize: 12
    }
  },
  series: [
    {
      name: "",
      type: "pie",
      radius: ["40%", "65%"],
      center: ["50%", "40%"],
      avoidLabelOverlap: false,
      // 关键代码========================
      label: {
        normal: {
          show: false,
          position: "outer",
          formatter: (item) => {
            let { name, value } = item;
            return `{a|${name}} {b|${value}}`;
          },
          // padding: [0, -58],
          rich: {
            a: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            b: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            c: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "left"
            },
            d: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "right"
            }
          }
        }
      },
      // 关键代码========================
      labelLine: {
        normal: {
          show: false,
          length: 5,
          length2: 50,
          lineStyle: {
            color: "#47A0FF"
          }
        }
      },
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: "rgba(0, 0, 0, 0.5)"
        }
      },
      data: [
        {name: "脱硫",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#008eec"},
                {offset: 1, color: "#008EEC"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "脱硝",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#5c82e3"},
                {offset: 1, color: "#5c82e3"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "炸药",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#d5ca00"},
                {offset: 1, color: "#d5ca00"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "切焊加热",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#e3675c"},
                {offset: 1, color: "#e3675c"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "直接释放",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "rgba(162,227,92,0.85)"},
                {offset: 1, color: "rgba(162,227,92,0.85)"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
      ]
    }
  ]
};
//碳交易
const yjdjgdtj = {
  tooltip: {
    show: true,
    trigger: 'item',
    formatter: '{b}t'
  },
  legend: {
    bottom: "20",
    // right: "20px",
    // orient: "vertical", // 垂直显示图例
    icon: "roundRect",
    itemHeight: 12,
    itemWidth: 20,
    itemGap: 10,
    textStyle: {
      //图例文字的样式
      color: "#FFFFFF",
      fontSize: 12
    }
  },
  series: [
    {
      name: "",
      type: "pie",
      radius: ["0%", "65%"], // 修改为实心圆
      center: ["50%", "40%"],
      avoidLabelOverlap: false,
      // 关键代码========================
      label: {
        normal: {
          show: false,
          position: "outer",
          formatter: (item) => {
            let { name, value } = item;
            return `{a|${name}} {b|${value}}`;
          },
          rich: {
            a: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            b: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            c: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "left"
            },
            d: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "right"
            }
          }
        }
      },
      labelLine: {
        normal: {
          show: false,
          length: 5,
          length2: 50,
          lineStyle: {
            color: "#47A0FF"
          }
        }
      },
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: "rgba(0, 0, 0, 0.5)"
        }
      },
      data: [
        {name: "CCER",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#008eec"},
                {offset: 1, color: "#008EEC"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "碳汇普",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "rgba(162,227,92,0.85)"},
                {offset: 1, color: "rgba(162,227,92,0.85)"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
      ]
    }
  ]
};

//碳抵消
const yjlxgdtj = {
  tooltip: {
    show: true,
    trigger: 'item',
    formatter: '{b}t'
  },
  legend: {
    bottom: "20",
    // right: "20px",
    // orient: "vertical", // 垂直显示图例
    icon: "roundRect",
    itemHeight: 12,
    itemWidth: 20,
    itemGap: 10,
    textStyle: {
      //图例文字的样式
      color: "#FFFFFF",
      fontSize: 12
    }
  },
  series: [
    {
      name: "",
      type: "pie",
      radius: ["0%", "65%"],
      center: ["50%", "40%"],
      avoidLabelOverlap: false,
      // 关键代码========================
      label: {
        normal: {
          show: false,
          position: "outer",
          formatter: (item) => {
            let { name, value } = item;
            return `{a|${name}} {b|${value}}`;
          },
          // padding: [0, -58],
          rich: {
            a: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            b: {
              fontSize: 12,
              color: "#FFFFFF",
              padding: [5, 0, 0, 0]
            },
            c: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "left"
            },
            d: {
              fontSize: 16,
              color: "#FFFFFF",
              fontWeight: "bold",
              align: "right"
            }
          }
        }
      },
      // 关键代码========================
      labelLine: {
        normal: {
          show: false,
          length: 5,
          length2: 50,
          lineStyle: {
            color: "#47A0FF"
          }
        }
      },
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: "rgba(0, 0, 0, 0.5)"
        }
      },
      data: [
        {name: "绿化",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#008eec"},
                {offset: 1, color: "#008EEC"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "回收利用",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#5c63e3"},
                {offset: 1, color: "#5c82e3"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
        {name: "绿证",
          value: 0,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "rgba(162,227,92,0.85)"},
                {offset: 1, color: "rgba(162,227,92,0.85)"}],
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false
            }
          }
        },
      ]
    }
  ]
};
//碳排放总量
// 第一部分：柱状图配置（建议单独放在配置文件中）
const gdlxtj = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {
    show: false // 不需要图例
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '12%',
    containLabel: true
  },
  xAxis: {
    type: 'category',
    data: ['化石燃料', '电力热力', '过程排放', '碳交易', '碳抵消'],
    axisLabel: {
      color: '#FFFFFF',
      rotate: 45,
      fontSize: 12,
      interval: 0
    },
    axisTick: {
      alignWithLabel: true
    }
  },
  yAxis: {
    type: 'value',
    axisLabel: {
      color: '#FFFFFF',
      fontSize: 12
    },
    splitLine: {
      lineStyle: {
        type: 'dashed'
      }
    }
  },
  series: [{
    name: '排放量',
    type: 'bar',
    barWidth: '45%',
    label: {
      show: true,
      position: 'top',
      color: '#FFFFFF',
      fontSize: 12,
      formatter: '{c}'
    },
    itemStyle: {
      borderRadius: [4, 4, 0, 0],
      color: (params) => {
        const colors = [
          { start: '#008eec', end: '#008EEC' },
          { start: '#5c63e3', end: '#5c82e3' },
          { start: '#d5ca00', end: '#d5ca00' },
          { start: '#e3675c', end: '#e3675c' },
          { start: 'rgba(162,227,92,0.85)', end: 'rgba(162,227,92,0.85)' }
        ];
        return {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            { offset: 0, color: colors[params.dataIndex].start },
            { offset: 1, color: colors[params.dataIndex].end }
          ]
        };
      }
    }
  }]
};



export default {
  gdslqs,gdztzb,gdsbzb,yjdjgdtj,yjlxgdtj,gdlxtj
}
